package com.rainbow.gray.plugin.framework.starter.gateway.filter;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.core.Ordered;
import org.springframework.web.server.ServerWebExchange;

import com.rainbow.gray.plugin.framework.starter.gateway.context.GatewayStrategyContext;

import reactor.core.publisher.Mono;

public class DefaultGatewayStrategyClearFilter implements GatewayStrategyClearFilter {

    @Override
    public int getOrder() {
        return Ordered.LOWEST_PRECEDENCE - 1;
    }

    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        GatewayStrategyContext.clearCurrentContext();

        return chain.filter(exchange);
    }
}